using System;
using Sce.PlayStation.Core;

namespace Nyanimals
{
	public class CPlayerCarryWalkState : CPlayerBaseState
	{
		public CPlayerCarryWalkState(string szName, CPlayer pl) : base(szName, pl)
		{
		}

		public override void Enter ()
		{
			player.ChangeAnimation("carrywalk");
			// Console.WriteLine("PlayerCarryWalkState::Enter()");
		}

		public override void Exit ()
		{
			// Console.WriteLine("PlayerCarryWalkState::Exit()");
		}

		public override void Input ()
		{
			CInput input = CInput.Instance;			
		}

		public override void Update (float deltaTime)
		{
			if(player.LeftStick == Vector2.Zero)
			{
				owningMachine.ChangeState("carryidle");
			}
									
			// get our movement direction based on the camera
			CCamera cam = CCamera.Instance;
			Vector3 camX = cam.LocalMatrix.AxisX;
			Vector3 camZ = cam.LocalMatrix.AxisZ;
			
			Vector3 stickDirection = new Vector3(-player.LeftStick.X, 0.0f, -player.LeftStick.Y);
			Vector3 camDirectionX = new Vector3(camX.X, 0.0f, camX.Z) * stickDirection.X;
			Vector3 camDirectionZ = new Vector3(camZ.X, 0.0f, camZ.Z) * stickDirection.Z;
			
			player.Velocity = camDirectionX + camDirectionZ; 
		}
	}
}

